/*     */ package com.zimbra.cs.account.grouphandler;
/*     */ 
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.StringUtil;
/*     */ import com.zimbra.common.util.ZimbraLog;
/*     */ import com.zimbra.cs.account.Account;
/*     */ import com.zimbra.cs.account.Domain;
/*     */ import com.zimbra.cs.account.accesscontrol.ExternalGroup;
/*     */ import com.zimbra.cs.extension.ExtensionUtil;
/*     */ import com.zimbra.cs.gal.ZimbraGalGroupHandler;
/*     */ import com.zimbra.cs.ldap.IAttributes;
/*     */ import com.zimbra.cs.ldap.ILdapContext;
/*     */ import com.zimbra.cs.ldap.LdapClient;
/*     */ import com.zimbra.cs.ldap.LdapServerConfig.ExternalLdapConfig;
/*     */ import com.zimbra.cs.ldap.LdapUsage;
/*     */ import com.zimbra.cs.ldap.ZLdapContext;
/*     */ import java.util.Map;
/*     */ import java.util.concurrent.ConcurrentHashMap;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public abstract class GroupHandler
/*     */ {
/*  49 */   private static Map<String, HandlerInfo> sHandlers = new ConcurrentHashMap();
/*     */   public abstract boolean isGroup(IAttributes paramIAttributes);
/*     */   
/*     */   public abstract String[] getMembers(ILdapContext paramILdapContext, String paramString1, String paramString2, IAttributes paramIAttributes) throws ServiceException;
/*     */   
/*     */   public abstract boolean inDelegatedAdminGroup(ExternalGroup paramExternalGroup, Account paramAccount, boolean paramBoolean) throws ServiceException;
/*     */   
/*     */   private static class HandlerInfo { Class<? extends GroupHandler> mClass;
/*     */     
/*  58 */     public GroupHandler getInstance() { GroupHandler handler; try { handler = (GroupHandler)this.mClass.newInstance();
/*     */       } catch (InstantiationException e) {
/*  60 */         handler = GroupHandler.access$000();
/*     */       } catch (IllegalAccessException e) {
/*  62 */         handler = GroupHandler.access$000();
/*     */       }
/*  64 */       return handler;
/*     */     }
/*     */   }
/*     */   
/*     */   private static GroupHandler newDefaultHandler() {
/*  69 */     return new ZimbraGalGroupHandler();
/*     */   }
/*     */   
/*     */   private static HandlerInfo loadHandler(String className) {
/*  73 */     HandlerInfo handlerInfo = new HandlerInfo(null);
/*     */     try
/*     */     {
/*  76 */       handlerInfo.mClass = ExtensionUtil.findClass(className).asSubclass(GroupHandler.class);
/*     */     }
/*     */     catch (ClassNotFoundException e) {
/*  79 */       ZimbraLog.gal.warn("GAL group handler %s not found, default to ZimbraGalGroupHandler", new Object[] { className });
/*     */       
/*  81 */       handlerInfo.mClass = ZimbraGalGroupHandler.class;
/*     */     }
/*  83 */     return handlerInfo;
/*     */   }
/*     */   
/*     */   public static GroupHandler getHandler(String className) {
/*  87 */     if (StringUtil.isNullOrEmpty(className)) {
/*  88 */       return newDefaultHandler();
/*     */     }
/*     */     
/*  91 */     HandlerInfo handlerInfo = (HandlerInfo)sHandlers.get(className);
/*     */     
/*  93 */     if (handlerInfo == null) {
/*  94 */       handlerInfo = loadHandler(className);
/*  95 */       sHandlers.put(className, handlerInfo);
/*     */     }
/*     */     
/*  98 */     return handlerInfo.getInstance();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public ZLdapContext getExternalDelegatedAdminGroupsLdapContext(Domain domain, boolean asAdmin)
/*     */     throws ServiceException
/*     */   {
/* 113 */     String[] ldapUrl = domain.getAuthLdapURL();
/* 114 */     if ((ldapUrl == null) || (ldapUrl.length == 0)) {
/* 115 */       throw ServiceException.INVALID_REQUEST("ubable to search external group, missing zimbraAuthLdapURL", null);
/*     */     }
/*     */     
/*     */ 
/* 119 */     boolean startTLSEnabled = domain.isAuthLdapStartTlsEnabled();
/* 120 */     String bindDN = domain.getAuthLdapSearchBindDn();
/* 121 */     String bindPassword = domain.getAuthLdapSearchBindPassword();
/*     */     
/* 123 */     LdapServerConfig.ExternalLdapConfig ldapConfig = new LdapServerConfig.ExternalLdapConfig(ldapUrl, startTLSEnabled, null, bindDN, bindPassword, null, "search external group");
/*     */     
/*     */ 
/*     */ 
/* 127 */     return LdapClient.getExternalContext(ldapConfig, LdapUsage.EXTERNAL_GROUP);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/grouphandler/GroupHandler.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */